﻿namespace Snipps.Selectors
{
    using System.Windows;
    using System.Windows.Controls;

    using Snipps.Core.Entities;

    public class CompletionListItemDataTemplateSelector : DataTemplateSelector
    {
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            if (item is Snippet)
            {
                var element = container as FrameworkElement;

                if (element != null)
                {
                    return element.FindResource("SnippetCompletionListItemDataTemplate") as DataTemplate;
                }
            }
            else if (item is Tag || item is ProgrammingLang)
            {
                var element = container as FrameworkElement;

                if (element != null)
                {
                    return element.FindResource("SimpleCompletionListItemDataTemplate") as DataTemplate;
                }
            }

            return null;
        }
    }
}